package leetcode.code0053;

import leetcode.helper.MaxDebug;

public class Solution extends Solution53 {

	@Override
	public int maxSubArray(int[] nums) {
		int ans = nums[0];
		int min = Math.min(0, nums[0]);
		for (int i = 1; i < nums.length; i++) {
			nums[i] += nums[i - 1];
			ans = Math.max(ans, nums[i] - min);
			min = Math.min(min, nums[i]);
		}
		return ans;
	}

	public static void main(String[] args) {
		MaxDebug.debug14(new Solution());
		MaxDebug.debug58(new Solution());
		Solution so = new Solution();
		so.debug6();
		so.debug7();
	}

}
